#!/bin/bash
var=$$
while true; do
    status=`ps -ef | grep mysql | grep -v grep | grep -v $var`
    if [ -n "$status" ]; then
        echo "mysql is running"
    else
        systemctl start mysql
        echo "mysql is down, starting it"
    fi
    sleep 3
done
